package com.atguigu.excel;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.read.metadata.holder.ReadHolder;

import java.util.Map;

/**
 * @author: 亚当
 * @date: 2022年06月23日 14:08
 * @package: com.atguigu.excel
 * @Description: 读取Excel内容
 */
public class ExcelListener extends AnalysisEventListener<DemoData> {
    //一行一行读取Excel内容
    @Override
    public void invoke(DemoData demoData, AnalysisContext analysisContext) {
        System.out.println("######"+demoData+"###########");
    }
    //读取表头内容
    @Override
    public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
        System.out.println("表头："+headMap);
        String sno = headMap.get(0);
        String sname = headMap.get(1);
        System.out.println(sno+" "+sname);
    }

    //读取完后的操作
    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
